<?php
require '../../../zb_system/function/c_system_base.php';
require '../../../zb_system/function/c_system_admin.php';
$zbp->Load();
$action='root';
if (!$zbp->CheckRights($action)) {$zbp->ShowError(6);die();}
if (!$zbp->CheckPlugin('yangtata_auto_pic')) {$zbp->ShowError(48);die();}
InstallPlugin_yangtata_auto_pic();
if (count($_POST) > 0) {
    if (function_exists('CheckIsRefererValid')) {
        CheckIsRefererValid();
    }
	foreach($_POST as $key=>$val){
		   if($key != 'csrfToken'){
		   $zbp->Config('yangtata_auto_pic')->$key = $val;
		   }
	}    
    $zbp->SaveConfig('yangtata_auto_pic');
    $zbp->SetHint('good');
    Redirect('./main.php');
}
require $blogpath . 'zb_system/admin/admin_header.php';
require $blogpath . 'zb_system/admin/admin_top.php';
?>
<link rel="stylesheet" type="text/css" media="all" href="./file/css/layui.css" />
<link rel="stylesheet" type="text/css" media="all" href="./file/css/yangtata_auto_pic.css?v=<?php echo time();?>" />
<script type="text/javascript" src="./file/layui.js"></script>
<fieldset class="layui-elem-field layui-field-title"><legend>文章自动配图</legend></fieldset>  
<form class="layui-form yangtata_auto_pic" id="edit" name="edit" method="post" action="#">  
    <div class="layui-form-item">
        <label class="layui-form-label">配置说明：</label>
		<div class="layui-input-inline aus">
		    <p>1、图片是直接插入到文章详情页内容正文指定位置，还可选择是否随文章一起保存至数据库;</p>
			<p>2、插件配图是从目录\zb_users\plugin\yangtata_auto_pic\file\pics随机读取一张背景图片，你可以提前在本目录上传更多背景图片，图片名称用数字或字母，不要带中文或符号，注意图片版权及大小等问题;</p>
			<p>3、生成的配图保存在\zb_users\upload\auto_pic，图片名称即文章id;</p>
		</div>	
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">启用配图：</label>
		<div class="layui-input-inline">
		    <div class="radios">	
			<input type="radio" name="open" value="1" title="是" <?php yangtata_auto_pic_checked(1,(int)$zbp->Config('yangtata_auto_pic')->open); ?> >
			<input type="radio" name="open" value="0" title="否" <?php yangtata_auto_pic_checked(0,(int)$zbp->Config('yangtata_auto_pic')->open); ?> >	
			</div>	
			<span class="layui-form-mid layui-word-aux">关闭自动配图后，已经生成的图片不会删除</span>
		</div>	
    </div>  	
	<div class="layui-form-item">
        <label class="layui-form-label">跳过有图：</label>
		<div class="layui-input-inline">
		    <div class="radios">	
			<input type="radio" name="isnext" value="1" title="是" <?php yangtata_auto_pic_checked(1,(int)$zbp->Config('yangtata_auto_pic')->isnext); ?> >
			<input type="radio" name="isnext" value="0" title="否" <?php yangtata_auto_pic_checked(0,(int)$zbp->Config('yangtata_auto_pic')->isnext); ?> >	
			</div>	
			<span class="layui-form-mid layui-word-aux">如果文章内容中已经有图片，是否跳过生成</span>
		</div>	
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文字字体大小：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_size" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_size; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的字体大小。</div>
        </div>        
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">文字背景颜色：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_bg" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_bg; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的背景颜色，格式如：#FFFFFF，0则随机。</div>
        </div>        
    </div>    
	<div class="layui-form-item">
        <label class="layui-form-label">文字背景高度：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_bgh" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_bgh; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的背景高度  0自适应。</div>
        </div>        
    </div>    
	<div class="layui-form-item">
        <label class="layui-form-label">文字背景透明度：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_opacity" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_opacity; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的背景透明度 数字越小透明度越高 0表示完全透明。</div>
        </div>        
    </div> 
	<div class="layui-form-item">
        <label class="layui-form-label">文字透明度：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_alpha" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_alpha; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的透明度 数字越小透明度越小 0表示不透明。</div>
        </div>        
    </div> 
	<div class="layui-form-item">
        <label class="layui-form-label">文字颜色：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_textcolor" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_textcolor; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的颜色，格式如：#FFFFFF，0则随机色。</div>
        </div>        
    </div> 
	<div class="layui-form-item">
        <label class="layui-form-label">字体文件名称：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_font" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_font; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：水印文字的字体文件名称，插件自带可选有Alibaba-PuHuiTi-Heavy.ttf、AlimamaFangYuan.ttf、youshebth.ttf三种，可以自己上传字体文件至\zb_users\plugin\yangtata_auto_pic\file\picfonts。</div>
        </div>        
    </div> 
	<div class="layui-form-item">
        <label class="layui-form-label">图片格式：</label>
		<div class="layui-input-inline">
		    <div class="radios">
			<input type="radio" name="img_type" value="jpg" title="JPG" <?php yangtata_auto_pic_checked('jpg',(string)$zbp->Config('yangtata_auto_pic')->img_type); ?> >
			<input type="radio" name="img_type" value="png" title="PNG" <?php yangtata_auto_pic_checked('png',(string)$zbp->Config('yangtata_auto_pic')->img_type); ?> >	
			</div>
			<span class="layui-form-mid layui-word-aux">说明：注意切换格式后，如果该格式图片未生成的情况下，需要重新生成图片。</span>
		</div>
    </div>
	<div class="layui-form-item">
        <label class="layui-form-label">内容分段标签：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_rtag" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_rtag; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：填写你的文章内容是用什么html标签分段的，比如<input type="text" style="border:0;outline:none;background:#fff;cursor:pointer;color:#f00;text-align: left;" readonly="" value="p、div、span..."></div>
        </div>        
    </div>
	<div class="layui-form-item">
        <label class="layui-form-label">配图位置：</label>
        <div class="layui-input-inline">
            <input type="text" name="img_pos" size="30" value="<?php echo $zbp->Config('yangtata_auto_pic')->img_pos; ?>" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">说明：图片显示在第几个段落前，填数字即可，如果数字超过文章实际段落数量，将显示在文章最前面。</div>
        </div>        
    </div>	
	<div class="layui-form-item">
        <label class="layui-form-label">更新文章：</label>
		<div class="layui-input-inline">
		    <div class="radios">	
			<input type="radio" name="postedit" value="1" title="是" <?php yangtata_auto_pic_checked(1,(int)$zbp->Config('yangtata_auto_pic')->postedit); ?> >
			<input type="radio" name="postedit" value="0" title="否" <?php yangtata_auto_pic_checked(0,(int)$zbp->Config('yangtata_auto_pic')->postedit); ?> >	
			</div>	
			<span class="layui-form-mid layui-word-aux">生成图片后是否随文章内容一起更新入库</span>
		</div>	
    </div>
	<div class="layui-form-item">
        <label class="layui-form-label">侧栏导航：</label>
		<div class="layui-input-inline">
		    <div class="radios">
			<input type="radio" name="left_menu" value="1" title="开启" <?php yangtata_auto_pic_checked(1,(int)$zbp->Config('yangtata_auto_pic')->left_menu); ?> >
			<input type="radio" name="left_menu" value="0" title="关闭" <?php yangtata_auto_pic_checked(0,(int)$zbp->Config('yangtata_auto_pic')->left_menu); ?> >
			</div>
			<span class="layui-form-mid layui-word-aux">开启后会在左则显示插件菜单名称</span>
		</div>				
    </div>
	<input type="hidden" name="csrfToken" value="<?php echo $zbp->GetCSRFToken();?>">
    <button type="submit" class="layui-btn">保存更改</button>
</form>
<?php
echo '<script type="text/javascript">ActiveLeftMenu("yangtata_auto_pic");</script>';
require $blogpath . 'zb_system/admin/admin_footer.php';
RunTime();
?>